table(id=node.$id(),class=["table-block", node.$role()])
  if node['$title?']()
    caption.title !{node.$captioned_title()}
  if node.$attr('rowcount') != 0
    colgroup
      if node['$option?']('autowidth')
        each ccc in node.$columns()
          col
      else
        each col in node.$columns()
          col(style={width: col.$attr("colpcwidth")})
      - tblsecs =["$head","$foot","$body"]
      each tblsec in tblsecs
        if node.$rows()[tblsec]().length != 0
          - var tag = "t" + tblsec.substr(1);
          #{tag}
            each row in node.$rows()[tblsec]()
              tr
                each cell in row
                  if tblsec == "$head"
                    - cell_content = cell.$text()
                  else
                    if cell.$style() == "verse" || cell.$style() == "literal"
                      - cell_content = cell.$text()
                    else
                      - cell_content = cell.$content()
                  #{tblsec == "$head" ? "th" : "td"}(class=['tableblock', "halign-#{cell.$attr('halign')}", "valign-#{cell.$attr('valign')}"],
                  colspan=cell.$colspan(), rowspan=cell.$rowspan(),style=node.document.$attr('cellbgcolor', false) ? "background-color:#{node.document.$attr('cellbgcolor')}" : "")
                    if tblsec == "$head"
                      !{cell_content}
                    else
                      case cell.$style()
                        when "asciidoc"
                          div !{cell_content}
                        when "verse"
                          div.verse !{cell_content}
                        when "literal"
                          div.literal
                            pre !{cell_content}
                        when "header"
                          each text in cell_content
                            p.tableblock.header !{text}
                        default
                          each text in cell_content
                            p.tableblock !{text}